﻿
@{
    ViewBag.Title = "管理员登录";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

<div class="row">
    <form class="from" autocomplete="on" id="regfrom" >
        <div class="form-group">
            <label class="control-label" for="loginname">登录名</label>
            <input type="text" value="" placeholder="" id="loginname" class="form-control" required="required" />
        </div>
        <div class="form-group">
            <label class="control-label" for="loginpwd">密&nbsp;&nbsp;码</label>
            <input type="password" value="" id="loginpwd" class="form-control" required="required" />
        </div>
        <div class="form-group">
            <input type="button" value="登录" class="btn btn-primary" id="btnLogin" />

            <input type="reset" value="重置" class="btn btn-default" style="margin-left: 100px" />
        </div>
    </form>
</div>
<div class="row">
    <div id="tip">
        
    </div>
</div>
@section scripts
{
    <script>
        $(function() {
            //登录
            $("#btnLogin")
                .click(function () {
                    //var f = $("form:first");
                    var n = $("#loginname").val();
                    var p1 = $("#loginpwd").val();
                    if (!n) {
                        $("#loginname").focus();
                        alert("登录名不可以为空");
                        return;
                    }
                    if (!p1) {
                        $("#loginpwd").focus();
                        alert("密码不可以为空");
                        return;
                    }
                    $.post('/admin/adminaccount/login',
                        { Name: n, Pwd: p1 },
                        function (res) {
                            if (res.Code === 0) {
                                $("#tip").html("<div class='alert alert-success'  role='alert'>登录成</div>");
                                location.href = '/admin/user/index';
                            } else {
                                $("#tip").html("<div class='alert alert-danger' role='alert'>" + res.Msg + "</div>");
                            }
                        });

                });
        });
    </script>

}
